package com.aaa.sbms.controller;

import com.aaa.sbms.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("car")
public class CarController {

    @Autowired(required = false)
    private CarService carService;

    /**
     * 查询车辆信息
     * @return
     */
    @RequestMapping("cars")
    public Map cars(){
        return carService.cars();
    }

    /**
     * 分页查询车辆
     * @param map
     * @return
     */
    @RequestMapping("carPage")
    public Map carPage(@RequestParam Map map){
        return carService.carPage(map);
    }

    /**
     * 分页查询车辆审核记录
     * @param map
     * @return
     */
    @RequestMapping("carauditPage")
    public Map carauditPage(@RequestParam Map map){
        return carService.carauditPage(map);
    }

    /**
     * 分页查询车辆使用记录
     * @param map
     * @return
     */
    @RequestMapping("carusePage")
    public Map carusePage(@RequestParam Map map){
        return carService.carusePage(map);
    }

    /**
     * 分页查询车辆维修记录
     * @param map
     * @return
     */
    @RequestMapping("maintainCarPage")
    public Map maintainCarPage(@RequestParam Map map){
        return carService.carmaintainPage(map);
    }

    /**
     * 分页查询车辆加油记录
     * @param map
     * @return
     */
    @RequestMapping("carRefuelPage")
    public Map carRefuelPage(@RequestParam Map map){
        return carService.carrefuelPage(map);
    }

    /**
     * 查询一个车辆
     * @param carid
     * @return
     */
    @RequestMapping("carOne")
    public Map carOne(Integer carid){
        return carService.carOne(carid);
    }

    /**
     * 查询一个车辆审核记录
     * @param id
     * @return
     */
    @RequestMapping("carauditOne")
    public Map carauditOne(Integer id){
        return carService.carauditOne(id);
    }

    /**
     * 查询一个车辆使用记录
     * @param id
     * @return
     */
    @RequestMapping("caruseOne")
    public Map caruseOne(Integer id){
        return carService.caruseOne(id);
    }

    /**
     * 添加车辆
     * @param map
     * @return
     */
    @RequestMapping("addCar")
    public int addCar(@RequestBody Map map){
        return carService.addCar(map);
    }

    /**
     * 添加车辆申请
     * @param map
     * @return
     */
    @RequestMapping("addCarAudit")
    public int addCarAudit(@RequestBody Map map){
        return carService.addCarAudit(map);
    }

    /**
     * 添加车辆维修
     * @param map
     * @return
     */
    @RequestMapping("addMaintainCar")
    public int addMaintainCar(@RequestBody Map map){
        return carService.addCarMaintain(map);
    }

    /**
     * 添加车辆维修
     * @param map
     * @return
     */
    @RequestMapping("addCarRefuel")
    public int addCarRefuel(@RequestBody Map map){
        return carService.addCarRefuel(map);
    }

    /**
     * 更新车辆
     * @param map
     * @return
     */
    @RequestMapping("updateCar")
    public int updateCar(@RequestBody Map map){
        return carService.updateCar(map);
    }

    /**
     * 添加车辆维修
     * @param carid
     * @return
     */
    @RequestMapping("deleteCar")
    public int deleteCar(Integer carid){
        return carService.deleteCar(carid);
    }

    /**
     * 车辆申请审核
     * @param map
     * @return
     */
    @RequestMapping("audit")
    public int audit(@RequestBody Map map){
        return carService.audit(map);
    }
}
